package com.ita.iosc.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.iosc.bean.Dish;
import com.ita.iosc.service.DishManager;
import com.ita.iosc.service.MerchantManager;
import com.ita.iosc.service.impl.DishManagerImpl;
import com.ita.iosc.service.impl.MerchantManagerImpl;

/**
 * Servlet implementation class ListAllDishServlet
 */
public class ListAllDishServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    DishManager dishManager = new DishManagerImpl();
    MerchantManager merchantManager = new MerchantManagerImpl();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListAllDishServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int mid = Integer.parseInt(request.getParameter("mid"));
		List<Dish> list = dishManager.listAllDishByMerchant(mid);
		request.setAttribute("merchant", merchantManager.findMerchantById(mid));
		request.setAttribute("dishList", list);
		request.getRequestDispatcher("./jsp/client/listDish.jsp").forward(request, response);
	}

}
